package main

import (
	"net/http"
)

func cors(f http.HandlerFunc) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("Access-Control-Allow-Origin", "*")                                                            // 允许访问所有域，可以换成具体url，注意仅具体url才能带cookie信息
		w.Header().Add("Access-Control-Allow-Headers", "Content-Type,AccessToken,X-CSRF-Token, Authorization, Token") //header的类型
		w.Header().Add("Access-Control-Allow-Credentials", "true")                                                    //设置为true，允许ajax异步请求带cookie信息
		w.Header().Add("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")                             //允许请求方法
		w.Header().Set("content-type", "application/json;charset=UTF-8")                                              //返回数据格式是json
		if r.Method == "OPTIONS" {
			w.WriteHeader(http.StatusNoContent)
			return
		}
		f(w, r)
	}
}
func index(w http.ResponseWriter, r *http.Request) {
	w.Write([]byte("Hello Golang"))
}
func GetStockList() []string {
	stockList := []string{"sz002232", "sz000812", "sz002951", "sz002432", "sz001317", "sh600559"}
	return stockList
}

var stockList = ""

func main() {

}
func e1(string) string {
	var j int
	for j = 0; j < 6; j++ {
		stockList = "http://hq.sinajs.cn/list=" + GetStockList()[j] + ","
	}

	return stockList

}
